<?php
/**
 * action过滤器适配
 *
 * @package if
 * @subpackage util.filter.action
 * @since 1.0
 */
class IActionFilter extends IObject implements IFilter {
	private $controller;
	private $params = array();
	
	function doFilter (&$controller, $chain = null) {
		$this->controller = $controller;
		if ($chain) {
			$chain->doNext();
		}
	}
	
	function _before(&$controller) {
		$this->controller = $controller;
	}
	
	function _after(&$controller) {
		$this->controller = $controller;
	}
	
	/**
	 * Enter description here...
	 *
	 * @return IController
	 * @since 1.0
	 */
	function controller() {
		return $this->controller;
	}
	
	/**
	 * 设置一个或一组参数
	 *
	 * @param string $name 参数名或一组参数名值对
	 * @param mixed $value 参数值
	 * @since 1.1.0
	 */
	function setParam($name, $value = null) {
		if (is_array($name)) {
			$this->params = array_merge($this->params, $name);
		}
		else {
			$this->params[] = $value;
		}
	}
	
	/**
	 * 取得参数值
	 *
	 * @param string $name 参数名
	 * @return mixed
	 * @since 1.1.0
	 */
	function param($name) {
		return isset($this->params[$name]) ? $this->params[$name] : null;
	}
	
	/**
	 * 取得所有参数
	 *
	 * @return array
	 * @since 1.1.0
	 */
	function params() {
		return $this->params;
	}
}


?>